<template>
  <div>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column v-for="{ key, label } in columns" :key="key" :label="label">
        <template slot-scope="{ row }">
          <slot :name="key" :row="row">{{ row[key] }}</slot>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      v-if="total > size"
      background
      layout="prev, pager, next"
      :total="total"
      :page-size="size"
      :current-page="page"
      @current-change="currentChange"
    >
    </el-pagination>
  </div>
</template>

<script>
export default {
  props: {
    tableData: {
      type: Array,
      required: true
    },
    columns: {
      type: Array,
      required: true
    },
    total: {
      type: Number,
      default: 0
    },
    page: {
      type: Number,
      default: 1
    },
    size: {
      type: Number,
      default: 10
    }
  },
  methods: {
    currentChange(page) {
      this.$emit('currentChange', page)
    }
  }
}
</script>

<style lang="scss" scoped></style>
